﻿#ifndef DAQ216_WRAPPER_H
#define DAQ216_WRAPPER_H

#include "libdaq/utils/wrapper_util.h"
#include <cstdint>

#ifdef __cplusplus
extern "C" {
#endif

// 设备生命周期管理
DLL_EXPORT uint32_t* CALL_FUNCTION DAQ216_New();
DLL_EXPORT void CALL_FUNCTION DAQ216_Delete(uint32_t* base_class);
DLL_EXPORT bool CALL_FUNCTION DAQ216_UseBackend(uint32_t* base_class, uint32_t* backend_class);
DLL_EXPORT bool CALL_FUNCTION DAQ216_InitializeDevice(uint32_t* base_class);
DLL_EXPORT bool CALL_FUNCTION DAQ216_ConnectedDevice(uint32_t* base_class);
DLL_EXPORT bool CALL_FUNCTION DAQ216_DisconnectedDevice(uint32_t* base_class);

// ADC配置函数
DLL_EXPORT bool CALL_FUNCTION DAQ216_ConfigADCTrigger(uint32_t* base_class, int type, int mode, int channel, int level);
DLL_EXPORT bool CALL_FUNCTION DAQ216_ConfigADCSampleRate(uint32_t* base_class, int sample_rate);
DLL_EXPORT bool CALL_FUNCTION DAQ216_ConfigADCVoltage(uint32_t* base_class, int voltage);
DLL_EXPORT bool CALL_FUNCTION DAQ216_ConfigADCVoltage_Batch(uint32_t* base_class, const int* range_array, int array_size);
DLL_EXPORT bool CALL_FUNCTION DAQ216_ConfigADCTriggerLength(uint32_t* base_class, uint32_t data_length);
DLL_EXPORT bool CALL_FUNCTION DAQ216_ConfigTriggerTimeout(uint32_t* base_class, uint32_t timeout);
DLL_EXPORT bool CALL_FUNCTION DAQ216_ConfigADCChannel(uint32_t* base_class, uint8_t channel);
DLL_EXPORT bool CALL_FUNCTION DAQ216_ConfigADCChannel_Batch(uint32_t* base_class, const bool* enable_array, int array_size);
DLL_EXPORT bool CALL_FUNCTION DAQ216_ConfigACDC(uint32_t* base_class, uint8_t channel);
DLL_EXPORT bool CALL_FUNCTION DAQ216_ConfigADCTriggerSource(uint32_t* base_class);

// 数据采集控制
DLL_EXPORT bool CALL_FUNCTION DAQ216_StartCollection(uint32_t* base_class);
DLL_EXPORT bool CALL_FUNCTION DAQ216_StopCollection(uint32_t* base_class);

// 数据读取函数
DLL_EXPORT bool CALL_FUNCTION DAQ216_TryReadData(uint32_t* base_class, uint8_t channel, float* read_buffer, uint32_t read_size, uint32_t timeout);
DLL_EXPORT bool CALL_FUNCTION DAQ216_TryReadData_Point(uint32_t* base_class, uint8_t channel, float* read_buffer);
DLL_EXPORT bool CALL_FUNCTION DAQ216_TryReadData_Batch(uint32_t* base_class, uint8_t channel, float* read_buffer, uint32_t read_size);

// 缓冲区管理
DLL_EXPORT bool CALL_FUNCTION DAQ216_ClearDataBuffer(uint32_t* base_class);
DLL_EXPORT bool CALL_FUNCTION DAQ216_ClearDataBuffer_Channel(uint32_t* base_class, uint8_t channel);

// 服务器信息
DLL_EXPORT bool CALL_FUNCTION DAQ216_GetServerInfo(uint32_t* base_class, char* ip_buffer, int ip_buffer_size, uint32_t* port);

// 设备信息获取
DLL_EXPORT bool CALL_FUNCTION DAQ216_ProductTestGetSN(uint32_t* base_class, char* sn_buffer, int buffer_size);
DLL_EXPORT bool CALL_FUNCTION DAQ216_GetSN(uint32_t* base_class, char* sn_buffer, int buffer_size);
DLL_EXPORT bool CALL_FUNCTION DAQ216_SystemOpGetDeviceName(uint32_t* base_class, char* name_buffer, int buffer_size);
DLL_EXPORT bool CALL_FUNCTION DAQ216_GetDeviceName(uint32_t* base_class, char* name_buffer, int buffer_size);

// 基本信息获取
DLL_EXPORT bool CALL_FUNCTION DAQ216_BasicInfoGetDeviceType(uint32_t* base_class);
DLL_EXPORT bool CALL_FUNCTION DAQ216_BasicInfoGetHardwareVersion(uint32_t* base_class, char* version_buffer, int buffer_size);
DLL_EXPORT bool CALL_FUNCTION DAQ216_BasicInfoGetBootLoaderVersion(uint32_t* base_class, char* version_buffer, int buffer_size);
DLL_EXPORT bool CALL_FUNCTION DAQ216_BasicInfoGetSoftwareVersion(uint32_t* base_class, char* version_buffer, int buffer_size);

// 版本信息获取
DLL_EXPORT bool CALL_FUNCTION DAQ216_GetDeviceType(uint32_t* base_class, char* type_buffer, int buffer_size);
DLL_EXPORT bool CALL_FUNCTION DAQ216_GetHardwareVersion(uint32_t* base_class, char* version_buffer, int buffer_size);
DLL_EXPORT bool CALL_FUNCTION DAQ216_GetBootLoaderVersion(uint32_t* base_class, char* version_buffer, int buffer_size);
DLL_EXPORT bool CALL_FUNCTION DAQ216_GetSoftwareVersion(uint32_t* base_class, char* version_buffer, int buffer_size);

// ADC参数获取
DLL_EXPORT bool CALL_FUNCTION DAQ216_GetADCLegalSampleRate(uint32_t* base_class, uint32_t* rate_array, int* array_size);
DLL_EXPORT uint32_t CALL_FUNCTION DAQ216_GetCurrentSampleRate(uint32_t* base_class);
DLL_EXPORT uint8_t CALL_FUNCTION DAQ216_GetADCLegalChannelSize(uint32_t* base_class);
DLL_EXPORT uint32_t CALL_FUNCTION DAQ216_GetADCBufferDataSize(uint32_t* base_class, int channel);
DLL_EXPORT uint32_t CALL_FUNCTION DAQ216_GetADCBufferDataMaxSize(uint32_t* base_class);
DLL_EXPORT uint32_t CALL_FUNCTION DAQ216_GetADCLegalLengthMin(uint32_t* base_class);
DLL_EXPORT uint32_t CALL_FUNCTION DAQ216_GetADCLegalLengthMax(uint32_t* base_class);
DLL_EXPORT uint8_t CALL_FUNCTION DAQ216_GetChannelEnableState(uint32_t* base_class);

// 参数验证函数
DLL_EXPORT bool CALL_FUNCTION DAQ216_ADCSampleRateIsLegal(uint32_t* base_class, uint32_t sample_rate);
DLL_EXPORT bool CALL_FUNCTION DAQ216_ADCRangeIsLegal(uint32_t* base_class, int range);

// 配置信息获取
DLL_EXPORT bool CALL_FUNCTION DAQ216_GetADCLegalChannel(uint32_t* base_class, uint32_t* channel_array, int* array_size);
DLL_EXPORT bool CALL_FUNCTION DAQ216_GetADCLegalVoltage(uint32_t* base_class, uint32_t* voltage_array, int* array_size);
DLL_EXPORT bool CALL_FUNCTION DAQ216_GetCurrentTriggerType(uint32_t* base_class, uint32_t* trigger_type);
DLL_EXPORT bool CALL_FUNCTION DAQ216_GetCurrentTriggerMode(uint32_t* base_class, uint32_t* trigger_mode);
DLL_EXPORT bool CALL_FUNCTION DAQ216_GetChannelEnableList(uint32_t* base_class, bool* enable_array, int* array_size);
DLL_EXPORT bool CALL_FUNCTION DAQ216_GetADCCurrentVoltage(uint32_t* base_class, uint32_t* voltage_array, int* array_size);

#ifdef __cplusplus
}
#endif

#endif // DAQ216_WRAPPER_H 